<?php
// author: Moore Jiang.
	ini_set('display_errors',1);            //错误信息  
	ini_set('display_startup_errors',1);    //php启动错误信息  
	error_reporting(-1);                    //打印出所有的 错误信息  
	ini_set('error_log', dirname(__FILE__) . '/error2_log.txt'); 
$url = 'http://contests.acmicpc.info/contests.json';
//初始化
$ch = curl_init();
//设置选项，包括URL
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
//执行并获取HTML文档内容
$output = curl_exec($ch);
//释放curl句柄
curl_close($ch);
//打印获得的数据
// print_r($output);
$obj = json_decode($output);
// for ($i=0; $i < count($obj) ; $i++) {
// 	echo $obj[$i]->id;
// 	echo $obj[$i]->oj;
// }
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <link rel="icon" href="http://www.yinghualuowu.com/img/ico/bitbug_favicon.ico"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
  </head>

<body>
    <div class="container">
		<div class="jumbotron">
			<div id=main>
				<table width=80% align=center>
					<thead class=toprow>
						<tr>
							<th class="column-1">OJ</th>
							<th class="column-2">Name</th>
							<th class="column-3">Start Time</th>
							<th class="column-4">Week</th>
							<th class="column-5">Access</th>
						</tr>
					</thead>
					<tbody class="row-hover">
						<?php
					    for ($i=0; $i < count($obj); $i++) {
					        ?>
							<tr>
						  		<td> <?php echo $obj[$i]->oj; ?> </td>
								<td class="column-2"><a id="<?php echo $obj[$i]->id; ?>" href=" <?php echo $obj[$i]->link; ?> " target="_blank"> <?php echo $obj[$i]->name; ?> </a></td>
								<td class="column-3"> <?php echo $obj[$i]->start_time; ?> </td>
								<td class="column-4"> <?php echo $obj[$i]->week; ?> </td>
								<td class="column-5"> <?php echo $obj[$i]->access; ?> </td>
						  	</tr>
						<?php
					    }
					    ?>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</body>
</html>
<!--not cached-->
